{% extends "base.html" %}
{% block content %}
	<h2 class="mb-4">
		<span class="me-2">
			<img src="{{ url_for('static', filename='icons/calendar-date.svg') }}" class="bi" width="32" alt="">
		</span>
		Upcoming Events
	</h2>

	<div class="row">
    {% for event in events %}
		<div class="col-md-4">
        	<div class="card mb-4">
          		<img src="{{ event.thumbnail }}" class="card-img-top" alt="{{ event.title }}" width="300">
        		<div class="card-body">
            		<h5 class="card-title">{{ event.title }}</h5>
            		<p class="card-text">{{ event.date }} @ {{ event.time }} SLT</p>
            		{% if admin==True %}
            		<a href="{{ url_for('delete_event', event_id=event.id) }}" class="btn btn-sm btn-danger">Delete</a>
            		{% endif %}
            	</div>
            </div>
        </div>
    {% endfor %}
	</div><!-- {{ admin }} -->

	{% if admin==True %}
	<hr class="mt-3">
	<h4 class="my-2">Add Event (Admin Only)</h4>
	<form method="POST">
		<div class="row g-2">
			<div class="col-md-6"><input class="form-control" name="title" placeholder="Title" required></div>
			<div class="col-md-6"><input class="form-control" name="thumbnail" placeholder="Image URL" required></div>
			<div class="col-md-4"><input class="form-control" name="date" placeholder="YYYY-MM-DD" required></div>
			<div class="col-md-4"><input class="form-control" name="time" placeholder="HH:MM" required></div>
			<div class="col-md-6"><input class="form-control" name="btc_address" placeholder="Admin BTC Address" required></div>
			<div class="col-md-6"><input class="form-control" name="signature" placeholder="Signed message" required></div>
			<div class="col-12"><button class="btn btn-primary mt-2">Add Event</button></div>
		</div>
	</form>
	{% endif %}
{% endblock %}
